﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;

namespace UnityTouchTable.Example
{
    /// <summary>
    /// 视频子内容节点
    /// </summary>
    [RequireComponent(typeof(VideoPlayer))]
    public class VideoContentNode : SubContentNodeBase
    {
        #region Field
        /// <summary>
        /// 播放器
        /// </summary>
        [SerializeField]
        [Header("播放器")]
        private VideoPlayer m_VideoPlayer = default;
        #endregion

        #region Function
        /// <summary>
        /// 显示
        /// </summary>
        /// <param name="centerRadius">中心节点半径</param>
        /// <param name="angle">角度</param>
        public override void Show(float centerRadius, float angle = 0.0f)
        {
            base.Show(centerRadius, angle);

            this.m_VideoPlayer.Play();
        }

        /// <summary>
        /// 隐藏
        /// </summary>
        /// <param name="exit">是否整体退出</param>
        public override void Hide(bool exit = false)
        {
            base.Hide(exit);

            this.m_VideoPlayer.Stop();
            if (this.m_VideoPlayer.targetTexture != null)
                this.m_VideoPlayer.targetTexture.Release();
        }
        #endregion
    }
}